﻿package app.view.components.guiDima 
{
	import app.view.components.guiDima.slideShowD.Image;
	import app.view.events.UIEvent;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import gs.TweenLite;
	
	/**
	 * Фото с рамкой
	 * @author www
	 */
	public class RamkaImageD extends Sprite
	{
		// app.view.components.guiDima.RamkaImageD
		
		public var bgd:Sprite;
		private var _image:Image;
		public static var IMAGE_X:Number = 22;
		public static var IMAGE_Y:Number = 21;
		private var _id:Number;
		
		public function RamkaImageD() 
		{
			init();
		}
		
		private function init():void
		{
			_image = new Image(bgd.width-1, bgd.height-2, Image.RESIZE_MAX, Image.ALIGN_CENTER);
			addChild(_image);
			_image.x = bgd.x;
			_image.y = bgd.y;
			
			
			addChild(bgd);
			
			this.alpha = 0;
		}
		
		public function destroy():void
		{
			
			_image.destroy();
			removeChild(_image);
			
			
		}
		
		public function setUrlImage(url:String):void
		{
			if (url!=null) 
			{
				_image.loadImage(url);
				
				this.buttonMode = this.useHandCursor = true;
				addEventListener(MouseEvent.CLICK, onCLickRamka);
				
				TweenLite.to(this, 0.4, { alpha: 1 ,ease:'none'} );
			}
			
		}
		
		private function onCLickRamka(e:MouseEvent):void 
		{
			var ev:UIEvent = new UIEvent(UIEvent.CLICK_ITEM_EVENT);
			ev.id = _id;
			dispatchEvent(ev);
		}
		
		public function get id():Number { return _id; }
		
		public function set id(value:Number):void 
		{
			_id = value;
		}
		
	}

}